package com.mvu.banana.domain.stub;
import java.util.ArrayList;
import javax.persistence.ElementCollection;
import javax.persistence.Column;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import java.util.List;
import com.mvu.banana.domain.impl.KeyableBean;
import javax.persistence.OneToMany;
import javax.persistence.Entity;

@Entity
public class Credential extends KeyableBean{

  @Column(unique = true)
  @Length(min = 2, max = 30)
  @NotNull
  protected String username;

  @Length(min = 2, max = 100)
  @NotNull
  protected String password;

  @ElementCollection
  protected List<String> permissions;

  @OneToMany
  protected List<Profile> profiles;

  public static final String USERNAME_PROP = "username";

  public static final String PASSWORD_PROP = "password";

  public static final String PERMISSIONS_PROP = "permissions";

  public static final String PROFILES_PROP = "profiles";

  public String getUsername(){
    return username;
  }

  public Credential setUsername(String p0){
    this.username = p0;
    return this;
  }

  public String getPassword(){
    return password;
  }

  public Credential setPassword(String p0){
    this.password = p0;
    return this;
  }

  public List<String> getPermissions(){
    if (permissions == null) {
      permissions = new ArrayList();
    };
    return permissions;
  }

  public Credential setPermissions(List<String> p0){
    this.permissions = p0;
    return this;
  }

  public List<Profile> getProfiles(){
    if (profiles == null) {
      profiles = new ArrayList();
    };
    return profiles;
  }

  public Credential setProfiles(List<Profile> p0){
    this.profiles = p0;
    return this;
  }

  public String toString(){
    StringBuilder builder = new StringBuilder();
    builder.append("username=").append(this.username).append(", ");
    builder.append("password=").append(this.password).append(", ");
    return builder.toString();
  }
}